/*
 *@author: YangJie
 *@date: 2021-04-09 13:47:55
 *@version:
 *@description:参数设置->公共配置->通用配置，包括验证配置、报修配置、推送配置、班次配置、移动端配置、保养计划配置、运行记录统计配置
 */
import React, { Component } from 'react';
import { Form, Tabs, Radio, Button, Table, Checkbox, Divider, Switch, Row, Col, List, Input, Drawer, InputNumber, Select, Card } from 'antd';
import '@/assets/css/settings';
import BasicConfirm from '../../../components_yyr/common/basicConfirm';
import BasicForm from '../../../components_yyr/common/basicForm';
import Paging from '../../../components_yyr/commponent/Paging';
const { TabPane } = Tabs;
const { Option } = Select;
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
//测试数据
const faultTimeoutDataSourceDemo = [
	{
		key: '1',
		id: '1',
		promoter: '林工,李工',
		timeInterval: '20',
		timeUnit: '分'
	}
];

const repairTimeoutDataSourceDemo = [
	{
		key: '1',
		id: '1',
		promoter: '管理员',
		timeInterval: '20',
		timeUnit: '分'
	}
];

const groupConfigDataSourceDemo = [
	{
		key: '1',
		id: 1,
		groupName: '234',
		timeRange: '1232',
		enabled: ''
	}
];
const dataSourceDemo = [
	{
		key: '1',
		id: 1,
		maintenanceTeam: '234',
		teamCode: '1232',
		teamType: ''
	}
];

const operatorDataSourceDemo = [
	{
		key: '1',
		id: 1,
		username: '管理员',
		name: '杨'
	}
];

const operatorInfoDataSourceDemo = [
	{
		key: '1',
		id: 1,
		username: '管理员',
		sex: '男',
		duty: '行政',
		department: '生产部',
		group: '001'
	}
];
class GeneralSettings extends Component {
	state = {
		loading: false, //加载中...
		dataSource: dataSourceDemo, //数据源
		total: 0, //总数据量
		formValues: {},
		// radioValue:[],
		//故障未响应超时推送
		faultTimeoutDataSource: faultTimeoutDataSourceDemo,
		faultDrawerVisible: false, //新增修改抽屉的显示与隐藏
		faultChooseData: {}, //用checkbox选择好的数据
		faultDrawerTitle: '', //抽屉的标题
		//维修超时推送
		repairTimeoutDataSource: repairTimeoutDataSourceDemo,
		repairDrawerVisible: false, //新增修改抽屉的显示与隐藏
		repairChooseData: {}, //用checkbox选择好的数据
		repairDrawerTitle: '', //抽屉的标题
		//班次配置
		groupDataSource: groupConfigDataSourceDemo,
		groupDrawerVisible: false,
		groupChooseData: {},
		groupDrawerTitle: '',
		//操作人
		operatorDataSource: operatorDataSourceDemo,
		//故障未响应超时推送->添加->添加
		operatorInfoDataSource: operatorInfoDataSourceDemo,
		operatorInfoDrawerVisible: false,
		operatorInfoChooseData: {},
		operatorInfoDrawerTitle: '',
		//分页
		total: 0, //总数据量
		formValues: {},
		//维修超时推送->添加->添加
		repairOperatorInfoDataSource: operatorInfoDataSourceDemo,
		repairOperatorInfoDrawerVisible: false,
		repairOperatorInfoChooseData: {},
		repairOperatorInfoDrawerTitle: ''
	};
	componentDidMount() {
		this.fetch({
			pageNum: 1,
			pageSize: 10
		});
	}
	//初始化加载数据
	fetch = data => {
		// this.setState({ loading: true })
		// this.post('/airCargo/pageList',{data}).then(res => {
		// 	this.setState({
		// 		loading: false,
		// 		dataSource: res.data.data,
		// 		total:res.data.total,
		// 		formValues:data
		// 	});
		// })
	};

	//表单查询
	filterSubmit = values => {
		values.pageNum = this.state.formValues.pageNum;
		values.pageSize = this.state.formValues.pageSize;
		this.fetch(values);
	};

	//radio相关->验证配置，报修配置，保养计划配置，运行记录统计配置
	onChange = e => {
		console.log('radio checked', e.target.value);
		this.setState({
			radioValue: e.target.value
		});
	};

	handleSelectTimeUnit = value => {
		console.log(value); //{key: "hours", label: "时"}
	};

	//故障未响应超时推送时的各个信息
	faultDrawerFormList = data => {
		const faultDrawerFormList = [
			{ type: 'INPUT', label: '时间间隔', field: 'timeInterval', initialValue: data.timeInterval },
			{ type: 'SELECT', label: '时间单位', field: 'timeUnit', initialValue: data.timeUnit },
			{ type: 'BUTTON', label: '添加', field: 'add' }
		];
		return faultDrawerFormList;
	};
	handleFaultSubmit = data => {
		const id = this.state.faultChooseData && this.state.faultChooseData.id;
		if (id) {
			data = Object.assign({}, data, { id: id });
			data.updateId = localStorage.getItem('userId');
		} else {
			data.createId = localStorage.getItem('userId');
		}
		this.post('/airCargo/addAirCargo', { data }).then(res => {
			this.success();
			this.fetch({ ...this.state.formValues });
			this.onClose();
		});
	};
	onFaultClose = () => {
		this.setState({
			faultDrawerVisible: false,
			faultChooseData: {}
		});
		// this.modalRef.props.form.resetFields();
	};

	//维修超时推送 时间间隔只允许输入数字，
	repairDrawerFormList = data => {
		const repairDrawerFormList = [
			{ type: 'INPUT', label: '时间间隔', field: 'timeInterval', initialValue: data.timeInterval },
			{ type: 'SELECT', label: '时间单位', field: 'timeUnit', initialValue: data.timeUnit, list: ['时', '分', '秒'] },
			{ type: 'BUTTON', label: '添加', field: 'add' }
		];
		return repairDrawerFormList;
	};
	handleRepairSubmit = data => {
		const id = this.state.repairChooseData && this.state.repairChooseData.id;
		if (id) {
			data = Object.assign({}, data, { id: id });
			data.updateId = localStorage.getItem('userId');
		} else {
			data.createId = localStorage.getItem('userId');
		}
		this.post('/airCargo/addAirCargo', { data }).then(res => {
			this.success();
			this.fetch({ ...this.state.formValues });
			this.onClose();
		});
	};
	onRepairClose = () => {
		this.setState({
			repairDrawerVisible: false,
			repairChooseData: {}
		});
		// this.modalRef.props.form.resetFields();
	};

	//班次配置
	groupDrawerFormList = data => {
		const groupDrawerFormList = [
			{ type: 'INPUT', label: '班次名称', field: 'groupName', initialValue: data.groupName },
			{ type: 'INPUT', label: '时间范围', field: 'startTime', initialValue: data.startTime },
			{ type: 'INPUT', label: '~', field: 'endTime', initialValue: data.endTime },
			{ type: 'SWITCH', label: '是否启用', field: 'enabled', rulesType: '', initialValue: data.enabled }
		];
		return groupDrawerFormList;
	};
	handleGroupSubmit = data => {
		const id = this.state.groupChooseData && this.state.groupChooseData.id;
		if (id) {
			data = Object.assign({}, data, { id: id });
			data.updateId = localStorage.getItem('userId');
		} else {
			data.createId = localStorage.getItem('userId');
		}
		this.post('/airCargo/addAirCargo', { data }).then(res => {
			this.success();
			this.fetch({ ...this.state.formValues });
			this.onClose();
		});
	};
	onGroupClose = () => {
		this.setState({
			groupDrawerVisible: false,
			groupChooseData: {}
		});
		this.modalRef.props.form.resetFields();
	};

	handleOperatorInfoSubmit = data => {
		const id = this.state.operatorInfoChooseData && this.state.operatorInfoChooseData.id;
		if (id) {
			data = Object.assign({}, data, { id: id });
			data.updateId = localStorage.getItem('userId');
		} else {
			data.createId = localStorage.getItem('userId');
		}
		this.post('/airCargo/addAirCargo', { data }).then(res => {
			this.success();
			this.fetch({ ...this.state.formValues });
			this.onClose();
		});
	};
	onOperatorInfoClose = () => {
		this.setState({
			operatorInfoDrawerVisible: false,
			operatorInfoChooseData: {}
		});
		// this.modalRef.props.form.resetFields();  //不注释掉，两个抽屉时的关闭会有问题
	};
	onRepairOperatorInfoClose = () => {
		this.setState({
			repairOperatorInfoDrawerVisible: false,
			repairOperatorInfoChooseData: {}
		});
		// this.modalRef.props.form.resetFields();
	};

	//删除确认
	handleDelConfirm = (value, api, chooseData, actionType) => {
		if (api === 1) {
			this.get(`/airCargo/delAirCargo?id=${chooseData.id}`).then(res => {
				this.success();
				this.fetch({ ...this.state.formValues });
			});
		}
	};

	// 打开modal，判断是修改还是新增 0新增 1修改
	handleModal = (actionType, data, recordType) => {
		if (actionType === 'EDIT' && recordType === 'FAULT') {
			this.setState({
				faultDrawerTitle: '编辑',
				faultDrawerVisible: true,
				faultChooseData: data
			});
		} else if (actionType === 'ADD' && recordType === 'FAULT') {
			this.setState({
				faultDrawerTitle: '添加',
				faultDrawerVisible: true
			});
		} else if (actionType === 'EDIT' && recordType === 'REPAIR') {
			this.setState({
				repairDrawerTitle: '编辑',
				repairDrawerVisible: true,
				repairChooseData: data
			});
		} else if (actionType === 'ADD' && recordType === 'REPAIR') {
			this.setState({
				repairDrawerTitle: '添加',
				repairDrawerVisible: true
			});
		} else if (actionType === 'EDIT' && recordType === 'GROUP') {
			this.setState({
				groupDrawerTitle: '编辑',
				groupDrawerVisible: true,
				groupChooseData: data
			});
		} else if (actionType === 'ADD' && recordType === 'GROUP') {
			this.setState({
				groupDrawerTitle: '添加',
				groupDrawerVisible: true
			});
		} else if (actionType === 'ADD' && recordType === 'OPERATOR') {
			this.setState({
				operatorInfoDrawerTitle: '基本信息',
				operatorInfoDrawerVisible: true
			});
		} else if (actionType === 'ADD' && recordType === 'REPAIR_OPERATOR') {
			this.setState({
				repairOperatorInfoDrawerTitle: '基本信息',
				repairOperatorInfoDrawerVisible: true
			});
		}
	};

	//验证配置中的元素  底层是看id
	verifyConfiguration = () => {
		const formList = [
			{
				key: '1',
				type: 'RADIO',
				label: '单位名称、单位编码、联系人',
				field: 'factoryName',
				col: 10,
				list: [
					{ id: '', key: 'repair', name: '维修' },
					{ id: '', key: 'maintain', name: '保养' }
				]
			},
			{}
		];
	};

	//记录checkbox的变化
	onCheckboxChange = checkedValues => {
		//猜测不同的一组数据应该用不同的数组来进行保存
		console.log('checked = ', checkedValues);
	};

	onSwitchChange = checked => {
		console.log(`switch to ${checked}`);
	};
	onRepairReportShowChange = checkedValues => {
		console.log('checked = ', checkedValues); //两个方法都没有取到值
	};
	onRepairReportChooseChange = checkedValues => {
		console.log('checked = ', checkedValues);
	};

	//头部关键字查询部分
	formoperatorInfoFormListList = () => {
		const formList = [
			{ type: 'INPUT', label: '姓名', field: 'factoryName', col: 6 },
			{ type: 'SELECT', label: '执行班组', field: 'recordTime', col: 6 },
			{ type: 'SELECT', label: '使用部门', field: 'message', placeholder: '请输入消息内容', col: 6 }
		];
		return formList;
	};
	//表单查询
	filterSubmit = values => {
		values.pageNum = this.state.formValues.pageNum;
		values.pageSize = this.state.formValues.pageSize;
		this.fetch(values);
	};

	render() {
		const { getFieldDecorator } = this.props.form;

		const { faultChooseData, faultDrawerVisible, faultDrawerTitle, faultTimeoutDataSource, repairChooseData, repairDrawerVisible, repairDrawerTitle, repairTimeoutDataSource, groupDataSource, groupDrawerVisible, groupChooseData, groupDrawerTitle, dataSource, loading, operatorDataSource } = this.state;
		const { operatorInfoDataSource, operatorInfoDrawerVisible, operatorInfoChooseData, operatorInfoDrawerTitle } = this.state;
		const { repairOperatorInfoDataSource, repairOperatorInfoDrawerVisible, repairOperatorInfoChooseData, repairOperatorInfoDrawerTitle } = this.state;
		const { total, formValues } = this.state;

		//序号旁的checkbox部分
		const rowSelection = {
			onChange: (selectedRowKeys, selectedRows) => {
				console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
			},
			getCheckboxProps: record => ({
				disabled: record.name === 'Disabled User', // Column configuration not to be checked
				name: record.name
			})
		};

		const formItemLayout = {
			labelCol: { xs: { span: 30 }, sm: { span: 4 } },
			layout: 'horizontal'
		};

		//故障未响应超时推送
		const faultDrawerProps = {
			onRef: ref => (this.modalRef = ref),
			visible: faultDrawerVisible,
			width: 600,
			// drawerFormList: this.faultDrawerFormList(faultChooseData),
			// submit: this.handleFaultSubmit,
			onClose: this.onFaultClose
			// title: faultDrawerTitle
		};
		//维修超时推送
		const repairDrawerProps = {
			onRef: ref => (this.modalRef = ref),
			visible: repairDrawerVisible,
			width: 600,
			drawerFormList: this.repairDrawerFormList(repairChooseData),
			// submit: this.handleRepairSubmit,
			onClose: this.onRepairClose
			// title: repairDrawerTitle
		};
		//班次配置
		const groupDrawerProps = {
			onRef: ref => (this.modalRef = ref),
			visible: groupDrawerVisible,
			width: 700,
			drawerFormList: this.groupDrawerFormList(groupChooseData),
			submit: this.handleGroupSubmit,
			onClose: this.onGroupClose,
			title: groupDrawerTitle
		};
		const operatorInfoDrawerProps = {
			onRef: ref => (this.modalRef = ref),
			visible: operatorInfoDrawerVisible,
			width: 700,
			// drawerFormList: this.groupDrawerFormList(operatorInfoChooseData),
			// submit: this.handleOperatorInfoSubmit,
			onClose: this.onOperatorInfoClose
			// title:operatorInfoDrawerTitle
		};

		const repairOperatorInfoDrawerProps = {
			onRef: ref => (this.modalRef = ref),
			visible: repairOperatorInfoDrawerVisible,
			width: 700,
			// drawerFormList: this.groupDrawerFormList(repairOperatorInfoChooseData),
			// submit: this.handleOperatorInfoSubmit,
			onClose: this.onRepairOperatorInfoClose
			// title: repairOperatorInfoDrawerTitle
		};

		//推送方式的选项
		const pushOptions = [
			{ label: '微信', value: 'wechat' },
			{ label: 'APP', value: 'qq' },
			{ label: '短信', value: 'note' },
			{ label: '邮箱', value: 'email' }
		];
		//额外配置的选项
		const extraConfigurationOptions = [
			{ label: '故障响应推送报修人', value: 'faultResponse' },
			{ label: '维修结束推送报修人', value: 'repairEnd' },
			{ label: '故障自动验证', value: 'validate' }
		];
		//故障未响应超时推送
		const faultTimeoutColumns = [
			{
				title: '操作',
				width: 150,
				dataIndex: 'action',
				render: () => (
					<span>
						<a onClick={() => this.handleModal('EDIT', faultTimeoutDataSource[0], 'FAULT')}>编辑</a>
						<Divider type="vertical" />
						<BasicConfirm title="确认删除?" api={1} buttonName="删除" data={''} handleConfirm={this.handleDelConfirm('FAULT')} />
					</span>
				)
			},
			{ title: '推送人', width: 150, dataIndex: 'promoter' },
			{ title: '时间间隔', width: 150, dataIndex: 'timeInterval' },
			{ title: '时间单位', dataIndex: 'timeUnit' }
		];
		//故障未响应超时推送->添加->操作人
		const operatorColumns = [
			{ title: '序号', width: 100, dataIndex: 'id' },
			{
				title: '操作',
				width: 150,
				dataIndex: 'delete',
				render: () => (
					<span>
						<BasicConfirm title="确认删除?" api={1} buttonName="删除" data={''} handleConfirm={this.handleDelConfirm} />
					</span>
				)
			},
			{ title: '用户名', width: 150, dataIndex: 'username' },
			{ title: '姓名', dataIndex: 'name' }
		];
		//维修超时推送
		const repairTimeoutColumns = [
			{
				title: '操作',
				width: 150,
				dataIndex: 'action',
				render: () => (
					<span>
						<a onClick={() => this.handleModal('EDIT', faultTimeoutDataSource[0], 'FAULT')}>编辑</a>
						<Divider type="vertical" />
						<BasicConfirm title="确认删除?" api={1} buttonName="删除" data={''} handleConfirm={this.handleDelConfirm} />
					</span>
				)
			},
			{ title: '推送人', width: 150, dataIndex: 'promoter' },
			{ title: '时间间隔', width: 150, dataIndex: 'timeInterval' },
			{ title: '时间单位', dataIndex: 'timeUnit' }
		];
		//班次配置
		const groupConfigColums = [
			{ title: '序号', width: 100, dataIndex: 'id' },
			{ title: '班次名称', width: 100, dataIndex: 'groupName' },
			{ title: '时间范围', width: 150, dataIndex: 'timeRange' },
			{
				title: '是否启用',
				width: 150,
				dataIndex: 'enabled',
				render: () => (
					<span>
						<Switch defaultChecked onChange={this.onSwitchChange} />
					</span>
				)
			}
		];
		//操作人具体信息
		const operatorInfoColumns = [
			{ title: '序号', width: 100, dataIndex: 'id' },
			{ title: '名称', width: 100, dataIndex: 'username' },
			{ title: '性别', width: 80, dataIndex: 'sex' },
			{ title: '职务', width: 100, dataIndex: 'duty' },
			{ title: '部门', width: 100, dataIndex: 'department' },
			{ title: '执行班组', dataIndex: 'group' }
		];
		//移动端配置->报修显示项
		const repairReportShowOptions = [
			{ key: '1', label: '紧急程度', value: '紧急程度', checked: 'false' },
			{ key: '2', label: '故障等级', value: '故障等级', checked: 'false' },
			{ key: '3', label: '故障类别', value: '故障类别', checked: 'false' },
			{ key: '4', label: '维修班组', value: '维修班组', checked: 'false' },
			{ key: '5', label: '设备位置', value: '设备位置', checked: 'false' },
			{ key: '6', label: '报修人', value: '报修人', checked: 'false' },
			{ key: '7', label: '联系电话', value: '联系电话', checked: 'false' },
			{ key: '8', label: '发生时间', value: '发生时间', checked: 'false' },
			{ key: '9', label: '是否停机', value: '是否停机', checked: 'false' }
		];
		//移动端配置->报修选择项
		const repairReportChooseOptions = [
			{ key: '1', label: '紧急程度', value: '紧急程度' },
			{ key: '2', label: '故障等级', value: '故障等级' },
			{ key: '3', label: '故障类别', value: '故障类别' },
			{ key: '4', label: '维修班组', value: '维修班组' },
			{ key: '5', label: '设备位置', value: '设备位置' },
			{ key: '6', label: '报修人', value: '报修人' },
			{ key: '7', label: '联系电话', value: '联系电话' },
			{ key: '8', label: '发生时间', value: '发生时间' },
			{ key: '9', label: '是否停机', value: '是否停机' },
			{ key: '10', label: '故障图片', value: '故障图片' },
			{ key: '11', label: '故障描述', value: '故障描述' }
		];

		//移动端配置->维修显示项
		const repairShowOptions = [
			{ key: '1', label: '维修班组', value: '维修班组', checked: 'false' },
			{ key: '2', label: '故障原因', value: '故障原因', checked: 'false' },
			{ key: '3', label: '维修级别', value: '维修级别', checked: 'false' },
			{ key: '4', label: '维修类型', value: '维修类型', checked: 'false' },
			{ key: '5', label: '紧急程度', value: '紧急程度', checked: 'false' },
			{ key: '6', label: '故障类别', value: '故障类别', checked: 'false' },
			{ key: '7', label: '发生时间', value: '发生时间', checked: 'false' },
			{ key: '8', label: '维修费用', value: '维修费用', checked: 'false' },
			{ key: '9', label: '设备部位', value: '设备部位', checked: 'false' },
			{ key: '10', label: '是否停机', value: '是否停机', checked: 'false' },
			{ key: '11', label: '故障等级', value: '故障等级', checked: 'false' },
			{ key: '12', label: '设备位置', value: '设备位置', checked: 'false' },
			{ key: '13', label: '报修人', value: '报修人', checked: 'false' },
			{ key: '14', label: '联系电话', value: '联系电话', checked: 'false' }
		];

		//移动端配置->维修选择项
		const repairChooseOptions = [
			{ key: '1', label: '维修班组', value: '维修班组', checked: 'false' },
			{ key: '2', label: '故障原因', value: '故障原因', checked: 'false' },
			{ key: '3', label: '维修级别', value: '维修级别', checked: 'false' },
			{ key: '4', label: '维修类型', value: '维修类型', checked: 'false' },
			{ key: '5', label: '故障类别', value: '故障类别', checked: 'false' },
			{ key: '6', label: '发生时间', value: '发生时间', checked: 'false' },
			{ key: '7', label: '维修费用', value: '维修费用', checked: 'false' },
			{ key: '8', label: '设备部位', value: '设备部位', checked: 'false' },
			{ key: '9', label: '是否停机', value: '是否停机', checked: 'false' },
			{ key: '10', label: '工作描述', value: '工作描述', checked: 'false' }
		];

		return (
			<div className="shadow-radius">
				<Tabs>
					<TabPane tab="报修配置" key="2">
						<div>
							<Form {...formItemLayout} onSubmit={this.handleRepairSubmit}>
								<FormItem label="是否可以无设备报修:">
									{getFieldDecorator('device-repairs', {
										initialValue: 'need-device-repairs'
									})(
										<RadioGroup onChange={this.onChange} name="device-repairs" defaultValue="no-device-repairs">
											<Radio value="need-device-repairs">是</Radio>
											<Radio value="no-device-repairs">否</Radio>
										</RadioGroup>
									)}
								</FormItem>
								<p className="warning-content">注：统一设置报修时是否必须选择系统有的设备，是否支持手动输入设备名称！</p>
								<FormItem label="是否允许同一设备多次报修:">
									{getFieldDecorator('repeated-repairs', {
										initialValue: 'repeated-repairs-yes'
									})(
										<RadioGroup onChange={this.onChange} name="repeated-repairs" defaultValue="repeated-repairs-yes">
											<Radio value="repeated-repairs-yes">是</Radio>
											<Radio value="repeated-repairs-no">否</Radio>
										</RadioGroup>
									)}
								</FormItem>
								<Button type="primary" htmlType="submit" onClick={this.handleRepairSubmit} style={{ marginLeft: '10%' }}>
									保存
								</Button>
							</Form>
						</div>
					</TabPane>
					<TabPane tab="推送配置" key="3">
						<div>
							<Form labelCol={{ xs: { span: 30 }, sm: { span: 2 } }} onSubmit={this.handlePushSubmit}>
								<FormItem label="推送方式:">
									<Checkbox.Group options={pushOptions} onChange={this.onCheckboxChange} />
									<span className="warning-content">注:推送包括：故障审核推送，维修推送，维修结束推送</span>
								</FormItem>
								<FormItem label="额外配置:">
									<Checkbox.Group options={extraConfigurationOptions} onChange={this.onCheckboxChange} />
								</FormItem>
								<div>
									<div className="content-title">故障未响应超时推送</div>
									<Button icon="plus" onClick={() => this.handleModal('ADD', {}, 'FAULT')} type="primary">
										{' '}
										添加
									</Button>
									<Table columns={faultTimeoutColumns} rowSelection={rowSelection} rowKey={(record, index) => index} dataSource={faultTimeoutDataSource} pagination={false} loading={loading} size="small" />
								</div>
								<div>
									<div className="content-title">维修超时推送</div>
									<Button icon="plus" onClick={() => this.handleModal('ADD', {}, 'REPAIR')} type="primary">
										{' '}
										添加
									</Button>
									<Table columns={repairTimeoutColumns} rowSelection={rowSelection} rowKey={(record, index) => index} dataSource={repairTimeoutDataSource} pagination={false} loading={loading} size="small" />
								</div>
								<FormItem>
									<Button type="primary" htmlType="submit" className={'btn'}>
										保存
									</Button>
								</FormItem>
							</Form>
						</div>
					</TabPane>
					<TabPane tab="班次配置" key="4">
						<div className="buttonList" style={{ textAlign: 'left' }}>
							<Button icon="plus" onClick={() => this.handleModal('ADD', groupConfigDataSourceDemo[0], 'GROUP')} type="primary">
								{' '}
								添加
							</Button>
							<Button icon="eye" onClick={() => this.handleModal('EDIT', groupConfigDataSourceDemo[0], 'GROUP')} type="primary">
								修改
							</Button>
							<BasicConfirm title="确认删除?" api={1} icon="delete" button={true} buttonName="删除" data={''} handleConfirm={this.handleDelConfirm} />
						</div>
						<Table columns={groupConfigColums} rowSelection={rowSelection} rowKey={(record, index) => index} dataSource={groupDataSource} pagination={false} loading={loading} />
					</TabPane>
					<TabPane tab="移动端配置" key="5">
						<Form onSubmit={this.handleConfigSubmit} style={{ width: 350, border: '1px rgb(224, 224, 224) solid', float: 'left' }}>
							<List
								size="small"
								header={<h3 style={{ fontWeight: 'bold', fontSize: '16px', margin: '10px' }}>报修显示项</h3>}
								style={{ width: 150, float: 'left' }}
								dataSource={repairReportShowOptions}
								split="false"
								renderItem={item => (
									<div style={{ margin: '5px 0px 5px 10px' }}>
										<Checkbox onChange={this.onRepairReportShowChange}>{item.value}</Checkbox>
									</div>
								)}
							/>
							<List
								size="small"
								header={<h3 style={{ fontWeight: 'bold', fontSize: '16px', margin: '10px' }}>报修显示项</h3>}
								style={{ width: 150, float: 'right' }}
								dataSource={repairReportChooseOptions}
								split="false"
								renderItem={item => (
									<div style={{ margin: '5px 0px 5px 10px' }}>
										<Checkbox onChange={this.onRepairReportChooseChange}>{item.value}</Checkbox>
									</div>
								)}
							/>
							<Button onClick={() => this.handleConfigSubmit} type="primary" style={{ margin: '10px 0 0 140px' }}>
								保存
							</Button>
						</Form>
						<Form onSubmit={this.handleConfigSubmit} style={{ width: 350, border: '1px rgb(224, 224, 224) solid', float: 'left' }}>
							<List
								size="small"
								header={<h3 style={{ fontWeight: 'bold', fontSize: '16px', margin: '10px' }}>报修显示项</h3>}
								style={{ width: 150, float: 'left' }}
								dataSource={repairShowOptions}
								split="false"
								renderItem={item => (
									<div style={{ margin: '5px 0px 5px 10px' }}>
										<Checkbox onChange={this.onRepairShowChange}>{item.value}</Checkbox>
									</div>
								)}
							/>
							<List
								size="small"
								header={<h3 style={{ fontWeight: 'bold', fontSize: '16px', margin: '10px' }}>报修显示项</h3>}
								style={{ width: 150, float: 'right' }}
								dataSource={repairChooseOptions}
								split="false"
								renderItem={item => (
									<div style={{ margin: '5px 0px 5px 10px' }}>
										<Checkbox onChange={this.onRepairChooseChange}>{item.value}</Checkbox>
									</div>
								)}
							/>
							<Button onClick={() => this.handleConfigSubmit} type="primary" style={{ margin: '10px 0 0 140px' }}>
								保存
							</Button>
						</Form>
					</TabPane>
					<TabPane tab="保养计划配置" key="6">
						<div className="content-title">保养计划配置</div>
						<Form onSubmit={this.handlePlanSubmit} labelCol={{ xs: { span: 30 }, sm: { span: 8 } }}>
							<FormItem label="导入保养计划时是否按照设备类型直接关联保养标准:">
								{getFieldDecorator('plan', {
									initialValue: 'plan-no'
								})(
									<RadioGroup onChange={this.onChange} name="verify-plan" defaultValue="plan-no">
										<Radio value="plan-yes">是</Radio>
										<Radio value="plan-no">否</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<Button type="primary" htmlType="submit" onClick={this.handlePlanSubmit} style={{ marginLeft: 450 }}>
								保存
							</Button>
						</Form>
					</TabPane>
					<TabPane tab="运行记录统计配置" key="7">
						<div className="content-title">运行记录统计配置</div>
						<p style={{ fontSize: 16 }}>运行记录统计分析时，确定分析字段使用总值或者平均值：</p>
						<Form labelCol={{ xs: { span: 30 }, sm: { span: 4 } }} onSubmit={this.handleRunRecordSubmit} style={{ fontWeight: 'bold' }}>
							<FormItem label="运行时间(R)" />
							<FormItem label="生存速率：(A)">
								{getFieldDecorator('survivalRate', {
									initialValue: 'maintenance-no'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="3">总值</Radio>
										<Radio value="4">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="良品数：(B)">
								{getFieldDecorator('goodNumber', {
									initialValue: 'maintenance-no'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="5">总值</Radio>
										<Radio value="6">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="产量：(C)">
								{getFieldDecorator('yield', {
									initialValue: 'maintenance-no'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="7">总值</Radio>
										<Radio value="8">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="计划时间（小时）：(D)">
								{getFieldDecorator('planTime', {
									initialValue: 'maintenance-no'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="9">总值</Radio>
										<Radio value="10">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="数字型5：(E)">
								{getFieldDecorator('numberTypeE', {
									initialValue: 'maintenance-no'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="11">总值</Radio>
										<Radio value="12">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="数字型6：(F)">
								{getFieldDecorator('numberTypeF', {
									initialValue: '13'
								})(
									<RadioGroup onChange={this.onChange} name="">
										<Radio value="13">总值</Radio>
										<Radio value="14">平均值</Radio>
									</RadioGroup>
								)}
							</FormItem>
							<FormItem label="统计公式：">
								<Input style={{ width: 100 }} />
								<label>=</label>
								<Input style={{ width: 200 }} allowClear />
							</FormItem>
							<Button type="primary" htmlType="submit" onClick={this.handleRunRecordSubmit} style={{ marginLeft: 200 }}>
								保存
							</Button>
						</Form>
					</TabPane>
				</Tabs>
				{/* <BasicDrawer {...faultDrawerProps} /> */}
				{/* <BasicDrawer {...repairDrawerProps} /> */}
				{/* <BasicDrawer {...groupDrawerProps} /> */}
				{/* 故障未响应超时推送 */}
				<Drawer {...faultDrawerProps}>
					<Form layout="horizontal">
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="时间间隔:">
									{getFieldDecorator('timeInterval', {
										rules: [{ required: true, message: '时间间隔必填' }]
									})(<Input />)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="时间单位:">
									{getFieldDecorator(
										'timeUnit',
										{}
									)(
										<Select labelInValue defaultValue={{ key: 'minutes' }} style={{ width: 120 }} onChange={this.handleSelectTimeUnit}>
											<Option key="hours" value="hours">
												时
											</Option>
											<Option key="minutes" value="minutes">
												分
											</Option>
											<Option key="seconds" value="seconds">
												秒
											</Option>
										</Select>
									)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Button icon="plus" onClick={() => this.handleModal('ADD', {}, 'OPERATOR')} type="primary">
								{' '}
								添加
							</Button>
						</Row>
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item>
									<Tabs>
										<TabPane key="1">
											<Table columns={operatorColumns} rowKey={(record, index) => index} dataSource={operatorDataSource} pagination={false} loading={loading} scroll={{ y: 500 }} />
										</TabPane>
									</Tabs>
								</Form.Item>
							</Col>
						</Row>
					</Form>
					<div style={{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right' }}>
						<Button type="primary" onClick={this.handleFaultSubmit} style={{ marginRight: 8 }}>
							保存
						</Button>
						<Button onClick={this.onFaultClose} style={{ marginRight: 8 }}>
							关闭
						</Button>
					</div>
				</Drawer>
				{/* 维修超时未推送 */}
				<Drawer {...repairDrawerProps}>
					<Form layout="horizontal">
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="时间间隔:">
									{getFieldDecorator('timeInterval', {
										rules: [{ required: true, message: '时间间隔必填' }]
									})(<Input />)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="时间单位:">
									{getFieldDecorator(
										'timeUnit',
										{}
									)(
										<Select labelInValue defaultValue={{ key: 'minutes' }} style={{ width: 120 }} onChange={this.handleSelectTimeUnit}>
											<Option key="hours" value="hours">
												时
											</Option>
											<Option key="minutes" value="minutes">
												分
											</Option>
											<Option key="seconds" value="seconds">
												秒
											</Option>
										</Select>
									)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Button icon="plus" onClick={() => this.handleModal('ADD', {}, 'REPAIR_OPERATOR')} type="primary">
								{' '}
								添加
							</Button>
						</Row>
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item>
									<Tabs>
										<TabPane key="1">
											<Table columns={operatorColumns} rowKey={(record, index) => index} dataSource={operatorDataSource} pagination={false} loading={loading} scroll={{ y: 500 }} />
										</TabPane>
									</Tabs>
								</Form.Item>
							</Col>
						</Row>
					</Form>
					<div style={{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right' }}>
						<Button type="primary" onClick={this.handleRepairSubmit} style={{ marginRight: 8 }}>
							保存
						</Button>
						<Button onClick={this.onRepairClose} style={{ marginRight: 8 }}>
							关闭
						</Button>
					</div>
				</Drawer>
				{/* 故障未响应超时推送的操作人子抽屉 */}
				<Drawer {...operatorInfoDrawerProps}>
					<Card>
						<BasicForm layout="vertical" formList={this.formoperatorInfoFormListList()} filterSubmit={this.filterSubmit} labelSpan={25} wrapperSpan={25} onRef={ref => (this.child = ref)} />
					</Card>
					<Form layout="horizontal">
						<Table columns={operatorInfoColumns} rowSelection={rowSelection} rowKey={(record, index) => index} dataSource={operatorInfoDataSource} pagination={false} loading={loading} scroll={{ y: 500 }} />
						<Paging total={total} formValues={formValues} fetch={pager => this.fetch(pager)} />
					</Form>
					<div style={{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right' }}>
						<Button type="primary" onClick={this.handleOperatorInfoSubmit} style={{ marginRight: 8 }}>
							保存
						</Button>
						<Button onClick={this.onOperatorInfoClose} style={{ marginRight: 8 }}>
							关闭
						</Button>
					</div>
				</Drawer>

				{/* {/* 维修超时未推送的操作人子抽屉 */}
				<Drawer {...repairOperatorInfoDrawerProps}>
					<Card>
						<BasicForm layout="vertical" formList={this.formoperatorInfoFormListList()} filterSubmit={this.filterSubmit} labelSpan={25} wrapperSpan={25} onRef={ref => (this.child = ref)} />
					</Card>
					<Form layout="horizontal">
						<Table columns={operatorInfoColumns} rowSelection={rowSelection} rowKey={(record, index) => index} dataSource={operatorInfoDataSource} pagination={false} loading={loading} scroll={{ y: 500 }} />
						<Paging total={total} formValues={formValues} fetch={pager => this.fetch(pager)} />
					</Form>
					<div style={{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right' }}>
						<Button type="primary" onClick={this.handleOperatorInfoSubmit} style={{ marginRight: 8 }}>
							保存
						</Button>
						<Button onClick={this.onRepairOperatorInfoClose} style={{ marginRight: 8 }}>
							关闭
						</Button>
					</div>
				</Drawer>
				{/* 班次配置 */}
				<Drawer {...groupDrawerProps}>
					<Form {...formItemLayout} layout="vertical" style={{ paddingLeft: 30, paddingTop: 0 }} labelCol={{ span: 4 }} dataSource={groupDataSource}>
						<Row gutter={16}>
							<Col span={24}>
								<Form.Item label="班次名称:">
									{getFieldDecorator('groupName', {
										rules: [{ required: true, message: '班次名称必填' }]
									})(<Input placeholder="请输入班次名称" />)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Col span={20}>
								<Form.Item label="时间范围:">
									{getFieldDecorator('startTime', {
										rules: [{ required: true, message: '开始时间必填' }]
									})(<InputNumber min={0} max={23} formatter={value => `${value}:00`} parser={value => value.replace(':00', '')} />)}
								</Form.Item>
							</Col>
							<Col span={1} style={{ marginLeft: -350 }}>
								<label>~</label>
							</Col>
							<Col span={3} style={{ marginLeft: -330 }}>
								<Form.Item>
									{getFieldDecorator('endTime', {
										rules: [{ required: true, message: '结束时间必填' }]
									})(<InputNumber defaultValue={0} min={0} max={23} formatter={value => `${value}:00`} parser={value => value.replace(':00', '')} />)}
								</Form.Item>
							</Col>
						</Row>
						<Row gutter={16}>
							<Col>
								<Form.Item label="是否启用">
									<Switch defaultChecked />
								</Form.Item>
							</Col>
						</Row>
					</Form>
					<div style={{ position: 'absolute', right: 0, bottom: 0, width: '100%', borderTop: '1px solid #e9e9e9', padding: '10px 16px', background: '#fff', textAlign: 'right' }}>
						<Button type="primary" onClick={this.handleGroupSubmit} style={{ marginRight: 8 }}>
							保存
						</Button>
						<Button onClick={this.onGroupClose} style={{ marginRight: 8 }}>
							关闭
						</Button>
					</div>
				</Drawer>
			</div>
		);
	}
}
export default Form.create()(GeneralSettings);

{
	/* <TabPane tab="验证配置" key="1">
						<div>
							<div className="content-title">验证配置</div>
							<Form {...formItemLayout} onSubmit={this.handleConfigSubmit}>
								<FormItem label="维修是否需要验证:">
									{getFieldDecorator('verify-repair', {
										initialValue: 'repair-no'
									})(
										<RadioGroup onChange={this.onChange} name="verify-repair" defaultValue="repair-no">
											<Radio value="repair-yes">是</Radio>
											<Radio value="repair-no">否</Radio>
										</RadioGroup>
									)}
								</FormItem>
								<FormItem label="保养是否需要验证:">
									{getFieldDecorator('verify-maintenance', {
										initialValue: 'maintenance-no'
									})(
										<RadioGroup onChange={this.onChange} name="verify-maintenance" defaultValue="maintenance-no">
											<Radio value="maintenance-yes">是</Radio>
											<Radio value="maintenance-no">否</Radio>
										</RadioGroup>
									)}
								</FormItem>
								<FormItem label="外委是否需要验证:">
									{getFieldDecorator('verify-outsource', {
										initialValue: 'outsource-no'
									})(
										<RadioGroup onChange={this.onChange} name="verify-outsource" defaultValue="outsource-no">
											<Radio value="outsource-yes">是</Radio>
											<Radio value="outsource-no">否</Radio>
										</RadioGroup>
									)}
								</FormItem>
								<p className="warning-content">注：统一设置维修单、保养等结束后是否需要验证！</p>
								<Button type="primary" htmlType="submit" onClick={this.handleConfigSubmit} style={{ marginLeft: 100 }}>
									保存
								</Button>
							</Form>
						</div>
					</TabPane> */
}
